﻿using BLL;
using MODEL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Loginter.运力查询
{
    public partial class SelectCarriersCar : System.Web.UI.Page
    {
        TruckTeamBLL truckteamBLL = new TruckTeamBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindTeam();
                GetBindTruckTeam();
            }
        }
        #region 车队名称绑定数据库
        /// <summary>
        /// 车队名称绑定数据库
        /// </summary>
        private void BindTeam()
        {
            DataTable table = truckteamBLL.GetTruckList();
            drop_truckteam.DataSource = table;
            drop_truckteam.DataTextField = "TeamName";
            drop_truckteam.DataValueField = "TeamID";
            drop_truckteam.DataBind();

            drop_truckteam.Items.Insert(0, new ListItem("--不限--", "0"));
        }
        #endregion

        #region 显示车队信息
        /// <summary>
        /// 显示车队信息
        /// </summary>
        private void GetBindTruckTeam()
        {
            int teamid = Convert.ToInt32(drop_truckteam.SelectedValue);
            string leader = txt_Leader.Text.Trim();
            int isdelete = Convert.ToInt32(rblDelete.SelectedValue);
            DataTable table = truckteamBLL.GetTruckTeamList(teamid, leader, isdelete);
            if (table == null)
            {
                Console.WriteLine("数据源为空！");
            }
            grive_select.DataSource = table;
            grive_select.DataBind();
        }
        #endregion

        #region 查询车队信息
        /// <summary>
        /// 查询车队信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_select_Click(object sender, EventArgs e)
        {
            GetBindTruckTeam();
        }
        #endregion


    }
}